﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

///==============================
//作者：李彰楠
//日期：2020/7/5
//
//名称：MsgCenter
//
//描述：管理各个模块的Manager的Manager
//
///==============================
namespace gameFramework_v1dot0_lzn
{
    /// <summary>
    /// Message Center:向各个manager转发message
    /// 注意事项：
    /// 1.程序启动，框架先初始化
    /// 2.manager要初始化完成
    /// 3.base才能进行初始化
    /// 
    /// MsgCenter最先进行初始化，MsgCenter的MonoManager设置为-300
    /// MsgCenter最先进行Awake，其他脚本再进行Awake
    /// </summary>
    public class MsgCenter : MonoBehaviour
    {
        //创建单例
        public static MsgCenter Instance = null;

        //加载UI预制体的路径
        public  string panelPrefabPath;
        //Json表的路径
        public  string jsonPath;
        public  string inventoryJsonPath;


        private void Awake()
        {
            
            Instance = this;
        
            
            //gameObject.AddComponent<SceneStateManager>();
            //gameObject.AddComponent<UIManager>();
            //gameObject.AddComponent<InventoryManager>();
            //gameObject.AddComponent<GameCoreManager>();
            //gameObject.AddComponent<CharactorManager>();
            //gameObject.AddComponent<GameCoreManager>();
            //if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "EditorMode"|| UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "GameCreatorMode" || UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "GamePaltformMode")
            //{
            //    gameObject.AddComponent<InventoryManager>();
            //}
            //if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "GameCreatorMode" || UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "GamePaltformMode")
            //{
            //    gameObject.AddComponent<GameCoreManager>();
            //}
            //gameObject.AddComponent<NPCManager>();
            //其他模块

            //转换场景不会被删除
            // GameObject.DontDestroyOnLoad(this.gameObject);
        }

        public void SendToMsg(MessageBase _tempMsg)
        {
            Debug.Log("MsgCebter:" + _tempMsg.msgId);
            AnalysisMsg(_tempMsg);
        }

        private void AnalysisMsg(MessageBase _tempMsg)
        {
            ManagerID tempId = _tempMsg.GetManager();

            switch (tempId)
            {
                case ManagerID.AssetManager:

                    break;
                case ManagerID.AudioManager:

                    break;
                case ManagerID.CharactorManager:
                    break;
                case ManagerID.MainManager:
                   
                    break;
                case ManagerID.NetManager:

                    break;
                case ManagerID.NPCManager:

                    break;
                case ManagerID.TerrianManager:

                    break;
                case ManagerID.UIManager:
                    //UIManager.Instance.ProcessEvent(_tempMsg);
                    
                    break;
                case ManagerID.InventoryManager:
                    //InventoryManager.Instance.ProcessEvent(_tempMsg);
                    break;
                default:

                    break;
            }

        }
    }

}

